#pragma once
#include ".\wx\generic\panelg.h"
#include "GraphicEngine.h"

#include "SignalClass.h"
#include "PlotDef.h"
//#include "Trigger.h"

const int MAX_PLOTS = 32;

class Plot :	public wxPanel
{
public:
	//Public methods
	Plot(wxWindow* parent, s32 Width, s32 Heigh,int frequency, int numSample, wchar_t *xlabel , wchar_t *ylabel , int vertDivision, bool labelFlag, bool gridFlag/*, int channel*/);
	~Plot(void);
	void DrawAll(void);
	
	//void AddTrigger(Trigger *trig);
	void SetTrigger(int kind, video::SColor color, wxString value);
	void ResetCurves (void);
	void AddCurve (SignalClass* signal);
	void AddCurves (SignalClass* signals, int n);
	int GetTime();
	
	//Public Variables
	GraphicEngine* Engine;
	//int Channel,
	int  lGraph,lRecord,xDivision;
	bool flagxLabel, GridFlag;
	video::SColor xColorLabel;
	int SampleFreq;
	int secLength;
	int numSignals;

private:
	//Private methods
	void DrawPlot (void);
	void DrawCorner(void);
   	void DrawGrid(int Lengtt, wchar_t *xLabel, wchar_t *yLabel, int num);
	void DrawSignal(void);
	core::position2d<s32> AbsPos4Signal(int numCh, float x, float y);
	core::position2d<s32> LabelPos(int numCh);
	void ResetTrigger(int time);
private:
	//Private variables
	
	int xBorder, yBorder,VerticalGap;
	int xEndBorder;
	int width, height;
	int gHeight, gWidth;
	unsigned long handle;
	SignalClass* Signals[MAX_PLOTS];
	trig *trigger;
	wchar_t *xLabel;
	wchar_t *yLabel;

	//EVENTS
	DECLARE_EVENT_TABLE();
	void OnMouseDown( wxMouseEvent& event );
	void OnMouseDoubleClick( wxMouseEvent& event );
	void OnMouseMove( wxMouseEvent& event );
};

